package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailClickBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailClickBean.DetailItem;
import o.azb;
import o.cgz;
import o.cii;
import o.cjk;
import o.cjm;
import o.cjo;
import o.ckt;
import o.emz;
import o.ewm.j;

public class DetailClickGeneralCard extends BaseDistCard implements OnClickListener {
    private TextView ʻ;
    private TextView ʼ;
    private TextView ʽ;
    private View ˊॱ;
    private LinearLayout ˋ;
    private ImageView ˏॱ;
    private boolean ͺ = true;
    private DetailClickBean ॱˊ;
    private TextView ॱॱ;
    private TextView ᐝ;

    public /* synthetic */ cgz ˏ(View view) {
        return ˊ(view);
    }

    public DetailClickGeneralCard(Context context) {
        super(context);
    }

    public DetailClickGeneralCard ˊ(View view) {
        this.ˋ = (LinearLayout) view.findViewById(j.ʽʻ);
        azb.ˏ(this.ˋ);
        this.ʼ = (TextView) view.findViewById(j.ʼﾞ);
        this.ॱॱ = (TextView) view.findViewById(j.ꜟᐝ);
        azb.ˏ(this.ॱॱ);
        this.ᐝ = (TextView) view.findViewById(j.ʼʹ);
        azb.ˏ(this.ᐝ);
        this.ʽ = (TextView) view.findViewById(j.ʿﾟ);
        azb.ˏ(this.ʽ);
        this.ʻ = (TextView) view.findViewById(j.ʽˈ);
        this.ˏॱ = (ImageView) view.findViewById(j.ʼꜞ);
        this.ˊॱ = view.findViewById(j.ʼꞌ);
        ʽ(view);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        this.ॱˊ = (DetailClickBean) cardBean;
        if (this.ॱˊ != null && this.ॱˊ.ॱ() != null && this.ॱˊ.ॱ().size() > 0) {
            this.ʼ.setText(this.ॱˊ.ˊ());
            int size = this.ॱˊ.ॱ().size();
            int i = 0;
            while (i < size && i <= 2) {
                switch (i) {
                    case 0:
                        ˊ(this.ॱॱ, i);
                        break;
                    case 1:
                        ˊ(this.ᐝ, i);
                        break;
                    case 2:
                        ˊ(this.ʽ, i);
                        break;
                    default:
                        break;
                }
                i++;
            }
            this.ˋ.setTag(this.ॱˊ.ॱॱ());
            if (this.ͺ) {
                this.ˊॱ.setOnClickListener(new ckt(this));
                return;
            }
            this.ʻ.setVisibility(4);
            this.ˏॱ.setVisibility(4);
        }
    }

    private void ˊ(TextView textView, int i) {
        textView.setText(((DetailItem) this.ॱˊ.ॱ().get(i)).ॱ());
        if (this.ͺ) {
            textView.setOnClickListener(new ckt(this));
        }
        textView.setId(i);
        textView.setVisibility(0);
    }

    public void onClick(View view) {
        String ॱॱ;
        int id = view.getId();
        if (view.getId() == j.ʼꞌ) {
            ॱॱ = this.ॱˊ.ॱॱ();
        } else if (id < 0 || id >= this.ॱˊ.ॱ().size()) {
            ॱॱ = null;
        } else {
            ॱॱ = ((DetailItem) this.ॱˊ.ॱ().get(id)).ˎ();
        }
        if (!TextUtils.isEmpty(ॱॱ)) {
            if (ॱॱ.startsWith("html|")) {
                int indexOf = ॱॱ.indexOf(124);
                if (indexOf != -1) {
                    ॱॱ = ॱॱ.substring(indexOf + 1);
                }
                emz.ॱ(view.getContext(), "internal_webview", ॱॱ);
                return;
            }
            BaseCardBean baseCardBean = new BaseCardBean();
            baseCardBean.ॱ(ॱॱ);
            baseCardBean.ˉ(this.ॱˊ.ͺˏ());
            Context context = view.getContext();
            if (!cii.ˊ().ˊ(context, baseCardBean)) {
                cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
                appDetailActivityProtocol.ˏ(new Request(this.ॱˊ.ॱॱ(), null));
                cjk.ˎ().ˋ(context, new cjm("appdetail.activity", appDetailActivityProtocol));
            }
        }
    }
}
